/*
2021-=7-16
https://www.acwing.com/problem/content/3772/
*/
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;
const int N=105;
int a[N];

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n,d;
        cin>>n>>d;
        for(int i=0;i<n;i++)
            cin>>a[i];
        
        int res=a[0];
        
        for(int i=1;i<n && d>=i;i++)
        {
            if(d>=a[i]*i)
            {
                res+=a[i];
                d-=a[i]*i;
            }
            else if(d<a[i]*i)
            {
                res+=d/i;
                d-=d/i*i;
            }
        }
        cout<<res<<endl;
    }
    return 0;
}
